/*****************************************************************************
 
 File:   OTKWorkspaceManager.java
 
 Date          Build     Author        Version    Comments
29-May-12    P-20-54    rkothari          $$1        Created

****************************************************************************/
package com.ptc.otkjavaexamples.ui;

import com.ptc.cipjava.jxthrowable;
import com.ptc.cipjava.stringseq;
import com.ptc.uifc.uifcInputPanel.InputPanel;
import com.ptc.uifc.uifcInputPanel.uifcInputPanel;
import com.ptc.uifc.uifcPushButton.DefaultPushButtonListener;
import com.ptc.uifc.uifcPushButton.PushButton;
import com.ptc.uifc.uifcTab.Tab;
import com.ptc.uifc.uifcTab.uifcTab;

/*
 * Listener class for PushButton "Clear" and "Cache Tools"  
 */
public class OTKCacheTools extends DefaultPushButtonListener
{	
    /*
     *  Override method OnActivate of DefaultPushButtonListener
     */	
    @Override
	public void OnActivate(PushButton handle) throws jxthrowable
    {
	/*
	 * On activating "Clear" button value in the cache space is reset to zero
	 */		
	if(handle.GetComponent().matches("clear_cache_pb"))
	    {	
		InputPanel cacheIp = uifcInputPanel.InputPanelFind(OTKServerRegistryDialog.OTK_SERVER_DIALOG, "total_cache_ip");
		cacheIp.SetIntegerValue(0);
	    }
	
	/*
	 * On activating "Cache Tools" button Tab will be switched to Servers
	 */
	else if(handle.GetComponent().matches("cache_tools_pb"))
	    {			
		Tab serverCacheTab = uifcTab.TabFind(OTKServerRegistryDialog.OTK_SERVER_DIALOG ,"server_cache_tab");
		stringseq selNames = stringseq.create();
		selNames.append("server_lay");
		serverCacheTab.SetSelectedItemNameArray(selNames);			
		
	    }
    }
    
}
